package library.operation;

import library.Book;
import library.BookList;

import java.util.Scanner;

//查找书籍
public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名：");
        String name = scanner.next();
        for (int i = 0;i < bookList.getSize();i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)) {
                System.out.print("找到书籍：");
                System.out.println("[" + i + "]" +book);
                return;
            }
        }
        System.out.println("未找到书籍。");
        return;
    }
}
